package cn.sccl.dirms.security.model;


import cn.sccl.common.model.TreeNode;
import cn.sccl.common.exception.BusinessException;

/**
* 系统菜单
* 数据库表 T_SEC_AUTHORITIES 的实体对象
* Created by 杨浩宇 on 2016-07-25.
*/
public class Authority extends TreeNode<Authority> implements Comparable {
/**
*表名
*/
public final static String TABLE_NAME ="t_sec_authorities";

    private java.lang.String name;//名称
    private java.lang.String displayName;//显示名称
    private java.lang.String authUrl;//访问URL
    private java.lang.String parentSelf;//父菜单
    private java.lang.String authType;//菜单类型，1=导航菜单，2=对象功能菜单
    private java.lang.String authPath;//页面对应的JS模块
    private java.lang.Long authIndex;//序号
    private boolean active;//是否有效，0=无效，1=有效
    private boolean readOnly;//是否只读菜单，0=否，1=是
    private java.lang.String sence;//场景
    private java.lang.String params;//菜单执行参数。key=value格式，多个参数用;隔开
    private java.lang.String icon;//图标样式
    private java.lang.Long loadType;//菜单加载方式。1=jquery.load方式，2=iframe方式，3=新开window方式
    private java.lang.String note;//备注

    @Override
    public void setName(java.lang.String name){
    this.name = name;
    }

        @Override
        public java.lang.String getName(){
    return this.name;
    }
    public void setDisplayName(java.lang.String displayName){
    this.displayName = displayName;
    }

        public java.lang.String getDisplayName(){
    return this.displayName;
    }
    public void setAuthUrl(java.lang.String authUrl){
    this.authUrl = authUrl;
    }

        public java.lang.String getAuthUrl(){
    return this.authUrl;
    }
    public void setParentSelf(java.lang.String parentSelf){
    this.parentSelf = parentSelf;
    }

        public java.lang.String getParentSelf(){
    return this.parentSelf;
    }
    public void setAuthType(java.lang.String authType){
    this.authType = authType;
    }

        public java.lang.String getAuthType(){
    return this.authType;
    }
    public void setAuthPath(java.lang.String authPath){
    this.authPath = authPath;
    }

        public java.lang.String getAuthPath(){
    return this.authPath;
    }
    public void setAuthIndex(java.lang.Long authIndex){
    this.authIndex = authIndex;
    }

        public java.lang.Long getAuthIndex(){
    return this.authIndex;
    }
    public void setActive(boolean active){
    this.active = active;
    }

        public boolean isActive(){
    return this.active;
    }
    public void setReadOnly(boolean readOnly){
    this.readOnly = readOnly;
    }

        public boolean isReadOnly(){
    return this.readOnly;
    }
    public void setSence(java.lang.String sence){
    this.sence = sence;
    }

        public java.lang.String getSence(){
    return this.sence;
    }
    public void setParams(java.lang.String params){
    this.params = params;
    }

        public java.lang.String getParams(){
    return this.params;
    }
    public void setIcon(java.lang.String icon){
    this.icon = icon;
    }

        public java.lang.String getIcon(){
    return this.icon;
    }
    public void setLoadType(java.lang.Long loadType){
    this.loadType = loadType;
    }

        public java.lang.Long getLoadType(){
    return this.loadType;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    /**
* clone一个对象。
* @param cls 需要克隆的对象类型，只能是当前类的子类
* @param
<T>
    * @return
    * @throws IllegalAccessException
    * @throws InstantiationException
    */
    public
    <T extends Authority> T clone(Class
        <T> cls) {
            try {
            T t = cls.newInstance();
            t.setId(this.
            getId());
            t.setName(this.
            getName());
            t.setDisplayName(this.
            getDisplayName());
            t.setAuthUrl(this.
            getAuthUrl());
            t.setParentSelf(this.
            getParentSelf());
            t.setAuthType(this.
            getAuthType());
            t.setAuthPath(this.
            getAuthPath());
            t.setAuthIndex(this.
            getAuthIndex());
            t.setCreateTime(this.
            getCreateTime());
            t.setUpdateTime(this.
            getUpdateTime());
            t.setDeleteFlag(this.isDeleteFlag());
            t.setActive(this.isActive());
            t.setReadOnly(this.isReadOnly());
            t.setSence(this.
            getSence());
            t.setParams(this.
            getParams());
            t.setIcon(this.
            getIcon());
            t.setLoadType(this.
            getLoadType());
            t.setNote(this.
            getNote());
            return t;
            } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("对象克隆失败，请克隆的目标对象是否具有无参的构造函数。", e.getCause());
            }
            }

    @Override
    public int compareTo(Object o) {
        Authority a = (Authority)o;
        Long other = a.getAuthIndex();
        return this.authIndex.compareTo(other);
    }

    @Override
    public String toString() {
        return "Authority{" +
                "name='" + name + '\'' +
                ", displayName='" + displayName + '\'' +
                '}';
    }
}